/*
 * LateBO.java
 *
 * Created on March 28, 2007, 7:00 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.jjenkins.data;

/**
 * This method contains all the set and get methods
 * @author Josh
 */
public class LateBO extends RevenueSourceBO{
    
    private int daysLate = 0;
    
    /** Creates a new instance of LateBO */
    public LateBO() {
    }
    
    /**
     * Sets the id
     * @param id String
     */
    public void setId(String id){
        this.id = id;
        this.setDirty(true);
    }
    
    /**
     * sets the daysLate
     * @param daysLate int
     */
    public void setDaysLate(int daysLate){
        this.daysLate = daysLate;
        setDirty(true);
    }
    
    /**
     * Creates a description
     * @return String
     */
    public String createDescription() {
        String desc = null;
        try{
            desc = FeeDAO.getInstance().read(this.getId()).createDescription();
        }catch (DataException e){
            e.printStackTrace();
        }
        return desc;
    }
    
    /**
     * Calculates and returns the price
     * @return double
     */
    public double calcPrice(){
        double price = 0;
        try{
            price = FeeDAO.getInstance().read(this.getId()).calcPrice();
        }catch(DataException e){
            e.printStackTrace();
        }
        return price;
    }
    
    /**
     * gets the number of days late
     * @return int
     */
    public int getDaysLate(){
        try{
            if(daysLate == 0){
                daysLate =((FeeBO)FeeDAO.getInstance().read(this.getId())).getRental().calcDaysOverdue();
            }
        }catch(DataException e){
            e.printStackTrace();
        }
        return daysLate;
    }
    
}
